import logging

from redis import StrictRedis


class Config:
    """项目配置"""
    DEBUG = True
    SECRET_KEY ="oRrRH1QvFaQyf1D89rzRMVNRVhdWUoLoADxswZfsYF5tXlV0T997C380Cmr9eh6J"
    # 为mysql添加配置
    SQLALCHEMY_DATABASE_URI = "mysql://root:qwe123@127.0.0.1:3306/information"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # redis配置
    REDIS_HOST = "127.0.0.1"
    REDIS_POST = 6379
    # session保存的位置
    SESSION_TYPE = "redis"
    # 开启session签名
    SESSION_USE_SIGNER = True
    # 指定session保存到redis中
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_POST)
    # 设置需要过期
    SESSION_PERMANENT = False
    # 设置过期时间
    PERMANENT_SESSION_LIFETIME = 86400 * 2
    # 设置日志等级
    LOG_LEVEL = logging.DEBUG


class DevelopmentConfig(Config):
    """开发环境"""
    DEBUG = True


class ProductionConfig(Config):
    """生产环境"""
    DEBUG = False
    LOG_LEVEL = logging.WARNING


class TestingConfig(Config):
    """单元测试环境"""
    DEBUG = True
    TESTING = True


config = {
    "development": DevelopmentConfig,
    "production": ProductionConfig,
    "testing": TestingConfig
}